package com.example.leetcode;

public class Singleton {
    private static volatile Singleton instant=null;
    private Singleton(){

    }
    public static Singleton getInstance(){
        if (instant==null){
            //synchronized(对象.class){
            synchronized(Singleton.class){
                if (instant==null){
                    instant=new Singleton();
                }
            }
        }
   return instant; }
}
